//
// Created by juno on 2021/9/12.
//

#ifndef WEBCHART_ROOM_ROOM_H
#define WEBCHART_ROOM_ROOM_H
#include <libwebsockets.h>

#include "member.h"

enum {
    ROOM_ERR_CODE_NOMEM = 1,
    ROOM_ERR_CODE_EXIST = 2,
    ROOM_ERR_CODE_UUID  = 3,
    ROOM_ERR_CODE_NOEXIST = 4
};


struct room_info {
    char *name;
    char *uuid;
    struct member_t *owner;
    unsigned int id;
};

struct room_t {
    struct room_info *info;
    struct member_t *member;
    struct room_t *next;
};

int room_new(struct room_info *info, struct room_t **res);
struct room_t *room_find_by_name(const char *name);
struct room_t *room_find_by_uuid(const char *uuid);
void rooms_iterator(void (*cb)(struct room_t *, void *), void *arg);
void room_destroy(struct room_t *room);

#endif //WEBCHART_ROOM_ROOM_H
